package lj.courseinterect.transfer;

import lj.courseinterect.entity.AnswerInfo;
import lj.courseinterect.entity.CourseInfo;
import lj.courseinterect.entity.QuestionInfo;
import lj.courseinterect.entity.Student;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by CatoldCui on 2015/5/24.
 */
public class QuestionBlockTranfer {
    int answerNum = 1;
    QuestionInfo questionInfo;
    Student student;
    CourseInfo courseInfo;
    List<AnswerInfo> answerInfos;

    public QuestionBlockTranfer(){

    }

    public QuestionBlockTranfer(int answerNum){
        this.answerNum = answerNum;
    }

    public QuestionInfo getQuestionInfo() {
        return questionInfo;
    }

    public void setQuestionInfo(QuestionInfo questionInfo) {
        this.questionInfo = questionInfo;
    }

    public Student getStudent() {
        return student;
    }

    public void setStudent(Student student) {
        if(student != null){
            student.setStuPwd("");
        }
        this.student = student;
    }

    public CourseInfo getCourseInfo() {
        return courseInfo;
    }

    public void setCourseInfo(CourseInfo courseInfo) {
        this.courseInfo = courseInfo;
    }

    public List<AnswerInfo> getAnswerInfos() {
        return answerInfos;
    }

    public void setAnswerInfos(List<AnswerInfo> answerInfos) {
        this.answerInfos = new ArrayList<AnswerInfo>();
        if(answerInfos != null){
            for(int i = 0; i < answerInfos.size() && i < this.answerNum; i++){
                //　控制大小
                // 判断是否缩短
                String ans = answerInfos.get(i).getAnsName();
                if(ans.length() > AnswerTransfer.MAXLENGTH){
                    answerInfos.get(i).setAnsName(ans.substring(0, AnswerTransfer.MAXLENGTH) + "...");
                }
                this.answerInfos.add(answerInfos.get(i));
            }
        }
    }

    public int getAnswerNum() {
        return answerNum;
    }

    public void setAnswerNum(int answerNum) {
        this.answerNum = answerNum;
    }
}
